package com.ly.hotel.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import android.os.Build;

import com.ly.hotel.common.Constants;



public class HardInfoUtil {
	
	/**
	 * mac的hashcode
	 * @return
	 */
	public static String getMacAddress(){
//		return "3333";
		String macFilePath = "/sys/class/net/eth0/address";
		
		File file = new File("/sys/class/net/eth0/address");
		if(!file.exists() || Build.BOARD.endsWith(Constants.BOARD_TYPE_RK3288_NAME)){//袁宝华的3288网口不能保存mac，需要从wifi那里获取
			macFilePath = "/sys/class/net/wlan0/address";
		}
		String mac =""; 
		
		try {
			Process pro = Runtime.getRuntime().exec("cat " + macFilePath);
			InputStreamReader inReader = new InputStreamReader(pro.getInputStream());
			BufferedReader bReader = new BufferedReader(inReader);
			String line = null;
			while( (line = bReader.readLine()) != null){
//				mac = String.valueOf(Math.abs(line.trim().hashCode())).trim();
				mac = line.trim();
			}
			return mac;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return mac;
	}
	
	
}
